package com.nxk.modules.utils;

import org.apache.shiro.crypto.SecureRandomNumberGenerator;
import org.apache.shiro.crypto.hash.SimpleHash;

public class Md5utils {

    /**
     * 根据用户名+密码，盐加密24次
     */
    public static String encryptPassword(String username, String password, String salt) {
        return new SimpleHash("md5", username + password, salt, 24).toHex().toString();
    }



    /**
     * 生成随机盐,字符串长度为6
     */
    public static String randomSalt() {
        SecureRandomNumberGenerator secureRandom = new SecureRandomNumberGenerator();
        String hex = secureRandom.nextBytes(3).toHex();
        return hex;
    }


    public static void main(String[] args) {
        String password = Md5utils.encryptPassword("admin1", "123456", "6e497c");
        System.out.println(password);
    }
}
